import java.util.Scanner;

public class demo5 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int q=scan.nextInt();
        for (int i = 0; i < q; i++) {
            int a2=scan.nextInt();
            int a3=scan.nextInt();
            int a4=scan.nextInt();
            int b4= scan.nextInt();
            int b6=scan.nextInt();
            System.out.println(b4*4+b6*6);
        }
    }
}
